import pandas as pd

def distion(df, col_List=["Avg"]):  # 文本筛选重建
    """
    决策布尔值创建器
    df = pd.DataFrame
    daylists=[5, 10, 21]
    """
    loop = 0

    col_L = ["date"]
    col_L.extend(col_List)
    df = df.loc[:, col_L]

    for key in col_L[1:]:
        tempL = []
        lists = []
        for day in range(df.shape[0] - 2):

            feature_dic = {"date": df.iloc[day + 1]["date"]}
            price1 = df.iloc[day][key]
            price2 = df.iloc[day + 1][key]
            price3 = df.iloc[day + 2][key]
            col = key + "_pre"

            if price1 > price2:
                feature_key = -1
            elif price1 < price2:
                feature_key = 1
            else:
                feature_key = 0

            tempL.append(feature_key)

            feature_dic[col] = feature_key
            lists.append(feature_dic)

        print("** Marker {} **".format(col).center(60, " "))

        df = pd.DataFrame(lists)
        df = pd.merge(df, df, on="date", how="left")

    return df